package com.xudow.app.ui;

import android.support.v4.app.Fragment;

import com.xudow.app.XApplication;
import com.xudow.app.ui.widget.LoadingDialog;

/**
 * A base fragment that handles common functionality in the app.
 *
 * @author lukcheng
 */
public abstract class BaseFragment extends Fragment {

    private LoadingDialog _loadingDialog;
    public XApplication getApp(){
       return  (XApplication)getActivity().getApplicationContext();
    }
    public BaseActivity getMyAct(){
        return (BaseActivity)getActivity();
    }



    /**
     * 显示加载对话框
     *
     * @param message
     */
    public void showLodingDialog(String message) {
        if (null != _loadingDialog) {          return;
        }
        _loadingDialog = new LoadingDialog(getActivity(), message);
        _loadingDialog.setCancelable(true);
        _loadingDialog.setCanceledOnTouchOutside(false);
        _loadingDialog.show();
    }

    /**
     * 隐藏登录对话框
     */
    public void hideLoadingDialog() {
        if (null != _loadingDialog && _loadingDialog.isShowing()) {
            _loadingDialog.dismiss();
            _loadingDialog = null;
        }
    }

}
